const randomArray = {
    arrList:[
        {name:"胡颖(组长)",group:"一组"},
        {name:"何润宏",group:"一组"},
        {name:"李志豪",group:"一组"},
        {name:"候华雨",group:"一组"},
        {name:"谢凯伦",group:"一组"},
        {name:"张家顺",group:"一组"},
        {name:"吴旭",group:"一组"},
        {name:"姚宗宝(组长)",group:"二组"},
        {name:"于贵",group:"二组"},
        {name:"徐溢洪",group:"二组"},
        {name:"陈立果",group:"二组"},
        {name:"张申德",group:"二组"},
        {name:"张也",group:"二组"},
        {name:"周斯佳",group:"二组"},
        {name:"刘杨",group:"二组"},
        {name:"朱鹏富(组长)",group:"三组"},
        {name:"赵中",group:"三组"},
        {name:"颜苗",group:"三组"},
        {name:"谭诗颖",group:"三组"},
        {name:"叶彬",group:"三组"},
        {name:"邓俊豪",group:"三组"},
        {name:"陈仲",group:"三组"},
        {name:"蒋超琼(组长)",group:"四组"},
        {name:"温鑫",group:"四组"},
        {name:"夏怀球",group:"四组"},
        {name:"刘帅",group:"四组"},
        {name:"朱澳",group:"四组"},
        {name:"高丽",group:"四组"},
        {name:"李虎",group:"四组"},
        {name:"钱宇亮",group:"四组"},
        {name:"孔德庆(组长)",group:"五组"},
        {name:"陈洁钰",group:"五组"},
        {name:"张家明",group:"五组"},
        {name:"徐涵",group:"五组"},
        {name:"沈晟平",group:"五组"},
        {name:"张志翔",group:"五组"},
        {name:"应子洋",group:"五组"},
        {name:"吴燚波",group:"五组"},
        {name:"凌佳晨",group:"五组"}
    ],
    // 随机打乱数组
    stochastic:function(){
        let newList = new Array();
        let key = 0;
        while(this.arrList.length>0){
             key = Math.floor(Math.random() * this.arrList.length);
             newList.push(this.arrList[key])
             this.arrList.splice(key,1)
        } 
        return newList
    },
    // 初始化页面
    init:function(){
        let oAward = document.getElementById('award')
        let oUserList = oAward.getElementsByClassName('userlist');
        let oOutOfOrder = oAward.getElementsByClassName('out-of-order');
        let self = this;
        let newList = this.stochastic();
        function initDOM(){
            oUserList[0].innerHTML = '';
            newList.forEach(function(value){
                // oUserList[0].innerHTML += '<li>'+value.group +' - '+ value.name+'</li>'
                let li = document.createElement('li');
                let textNode = document.createTextNode(value.group+' - '+value.name);
                li.appendChild(textNode)
                oUserList[0].appendChild(li)
            });
            return self
        }
        initDOM()
        oOutOfOrder[0].onclick=function(){
            self.arrList = newList;
            newList = self.stochastic();
            initDOM()
        }
        return this
    }

}

